package com.nhjf.dao.oranizationAccount;

import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.nhjf.dao.BaseDao;
import com.nhjf.model.oranizationAccount.OranizationAccount;
import com.nhjf.pojo.qo.oranizationAccount.OranizationAccountQo;
@Repository
public class OranizationAccountDao extends BaseDao<OranizationAccount,OranizationAccountQo>{

	@Override
	protected Criteria buildCriteria(Criteria criteria, OranizationAccountQo qo) {
		// TODO Auto-generated method stub
		if(qo!=null) {
			criteria.setFetchMode("organization", qo.isSeachOranization()?FetchMode.JOIN:FetchMode.SELECT);	
			if(qo.getAmount()!=null) {
				criteria.add(Restrictions.eq("amount",qo.getAmount()));
			}
			if(qo.getOranizationAccountId()!=null) {
				criteria.add(Restrictions.eq("id",qo.getOranizationAccountId()));
			}
			if(qo.getUpdateTime()!=null) {
				criteria.add(Restrictions.eq("updateTime",qo.getUpdateTime()));
			}
			if(qo.getOrganizationId()!=null) {
				criteria.add(Restrictions.eq("organization.id",qo.getOrganizationId()));
			}
			if(qo.getPendingSettlementAmount()!=null) {
				criteria.add(Restrictions.eq("pendingSettlementAmount",qo.getPendingSettlementAmount()));
			}
		}
		return criteria;
	}

	@Override
	protected Class<OranizationAccount> getEntityClass() {
		// TODO Auto-generated method stub
		return OranizationAccount.class;
	}

}
